package utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @author 崔书健
 * @date 2024/7/26
 */
public class BaseDao {

    /**
     * 返回数据库连接
     * @return
     */
    public static Connection getConnection(){
        Connection connection = null;
        String driver = ConfigManager.getInstance().getValue("jdbc.driver");
        String url = ConfigManager.getInstance().getValue("jdbc.url");
        String username = ConfigManager.getInstance().getValue("jdbc.username");
        String password = ConfigManager.getInstance().getValue("jdbc.password");
        try {
            Class.forName(driver);
            connection = DriverManager.getConnection(url,username,password);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return connection;
    }

}
